class Solution(object):
    def constructArray(self, n, k):
        """
        :type n: int
        :type k: int
        :rtype: List[int]
        """
        nums = [0] * n
        min_v = 1
        max_v = n
        t = 0
        for i in range(n):
            if t < k:
                if t % 2 == 0:
                    nums[i] = min_v
                    min_v += 1
                else:
                    nums[i] = max_v
                    max_v -= 1
                t += 1
            else:
                if k % 2 == 1:
                    nums[i] = min_v
                    min_v += 1
                else:
                    nums[i] = max_v
                    max_v -= 1
        return nums